package com.vfa.test;

import java.util.ArrayList;

import com.vfa.vocaburay.R;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AnswerAdapter extends ArrayAdapter<AnswerE>{

	private ArrayList<AnswerE> items;
	private final LayoutInflater mInflater;
	private final int mLayoutRes;
	private Context context;
	
	TextView  tvAnswer, tvAnswerNum, tvriro;
	ImageView img;
	
	public AnswerAdapter(Context context,	int textViewResourceId, ArrayList<AnswerE> answerItem) {
		super(context, textViewResourceId, answerItem);
		this.context = context;
		items = answerItem;
		this.mLayoutRes = textViewResourceId;
		this.mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent){
		View v;
		if(convertView == null){
			v=mInflater.inflate(mLayoutRes, parent, false);
		}
		else {
			
			v=convertView;
		}
		final AnswerE answer = items.get(position);
		if(answer !=null){
			tvAnswer = (TextView) v.findViewById(R.id.tv_answer_item);
			tvAnswerNum = (TextView)v.findViewById(R.id.tv_answernum_item);
			tvriro = (TextView)v.findViewById(R.id.tv_riro_item);
			if(tvAnswer !=null)
			{
				tvAnswer.setText(answer.getAnswer());
			}
			if(tvAnswerNum !=null)
			{
				tvAnswerNum.setText("Answer "+(position+1)+":");
			}
			if(tvriro !=null)
			{
				//tvriro.setText(String.valueOf(answer.getRiro()));
			}
		}
		return v;
	}

}
